home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0286.arc
/
FACT.C
< prev
next >
Wrap
Text File
|
1986-02-03
|
896b
|
39 lines
/************************************************************************/
/* */
/* fact.c */
/* */
/* Example Program to test recursion. */
/* */
/* This program attempts to compute 50! using double's. */
/* */
/* A. Skjellum */
/* November 29, 1985 */
/* */
/* */
/* Computer Language Magazine [C Interpreter Wrap-Up, Feb., 1986] */
/* */
/************************************************************************/
main()
{
int iter;
double factrl();
double x;
printf("fact.c: computes 50! one hundred times [29-Nov-85]\n\n");
for(iter = 1; iter <= 100; iter++)
x = factrl(50.0);
printf("50! = %e\n",x);
}
double factrl(x)
double x;
{
if(x <= 0.0)
return(1.0);
return(x*factrl(x - 1.0));
}